<template>
    <div class="components-container">
        <div class="header-form">
             <div class="layui-inline">
                <label class="layui-form-label">名称</label>
                 <div class="layui-input-inline">
                    <el-input v-model="selectData.SitnameLike" placeholder="请输入名称"></el-input>
                 </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label" >排序</label>
                 <div class="layui-input-inline">
                    <el-input v-model="selectData.SitnumLike" placeholder="请输入排序"></el-input>
                 </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label" >服务种类</label>
                <div class="layui-input-inline">
                    <!-- <input type="text" class="form-control" v-model="selectData.Sicname" placeholder="请选择服务种类"> -->
                    <el-select v-model="selectData.Sicname" placeholder="请选择服务种类" style="width:100%">
                         <el-option label="全部" :value="null"></el-option>
                        <el-option v-for="item in sicNames" :key="item.value" :label="item.label" :value="item.label"></el-option>
                    </el-select>
                </div>
            </div>
            <el-button type="primary"  @click="btnSearch" >搜索</el-button>
            <el-button  @click="btnRepeat">重置</el-button>
        </div>
        <!-- 功能列表 -->
        <div>
            <ul class="toolList">
                <li v-if="btnShow(item.BTNVALUE)" v-for="(item, index) in $store.state.btnListCommon" @click="operate(item.BTNVALUE)">
                    <el-button type="primary" :value="item.BTNSHOWNAME" v-text="item.BTNSHOWNAME"></el-button>
                </li>
            </ul>
        </div>
        <!--数据列表-->
        <dataTable :headList="headList" :dataList="dataList" :pageOrder="pageOrder" @pageChange="pageChange" @selectRow="selectRow"></dataTable>
        
        <serviceItemsManageMain ref="sweetModalMain" :orderType="order" @refreshData="getData"></serviceItemsManageMain>

        <staEndUse ref="useMain" @refreshData="getData"></staEndUse>
    </div>
</template>
<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/common.scss";
.el-form-item {
  margin-bottom: 0px;
}
.btnCenter {
  text-align: center;
}
</style>

<script>
import serviceItemsManageMain from "./serviceItemsManageMain";
import staEndUse from "./staEndUse";
import dataTable from "@/components/Table/DataTable";
import apiBase from "@/api/apiBase.js";
import { manage } from "@/mixins/managePage.js";
import { ORDER } from "@/const/orderConst.js";

const ADD = "新增";
const MODIFY = "修改";
const DELETE = "删除";
const INFO = "详情";
export default {
  name: "serviceItemsManage",
  mixins: [manage],
  data() {
    return {
      sicNames: [],
      selectData: {},
      Data: {}
    };
  },
  methods: {
    //功能操作
    operate(order) {
      this.order = order;
      this.dataRepeat();
      switch (this.order) {
        case ADD:
          this.$refs.sweetModalMain.open(this.order);
          break;
        case MODIFY:
        case DELETE:
        case INFO:
          this.$refs.sweetModalMain.open(this.order, this.currentRow.SITID);
          break;
        case ORDER.START:
        case ORDER.END:
          this.$refs.useMain.open(this.order, this.currentRow.SITID);
          break;
        default:
      }
    },
    //获取表头
    getColumns() {
      apiBase.DoService(
        {},
        apiBase.getApiAdress().Column.GetServiceitemsColumns,
        res => {
          this.headList = res.data.content;
        }
      );
    },
    //获取查询数据
    getData() {
      let Data = JSON.parse(JSON.stringify(this.selectData));
      console.log(1111,this.selectData);
      var data = {
        PageIndex: this.pageOrder.currentPage,
        PageSize: this.pageOrder.pageSize,
        OrderBy: this.pageOrder.orderType,
        OrderByType: this.pageOrder.orderSort,
        Data: Data
      };
      apiBase.DoService(
        data,
        apiBase.getApiAdress().Serviceitems.Query,
        res => {
          this.dataList = res.data.content.OutData;
          this.pageOrder.totalNum = res.data.content.RecordCount;
        }
      );
    },
    //获取位置类别
    getSic() {
      let data = {};
      apiBase.DoService(
        data,
        apiBase.getApiAdress().Serviceitems.QuerySic,
        res => {
          let sicNameData = res.data.content,
            legendsUsersData = sicNameData.map(item => ({
              label: item.SICNAME,
              value: item.SICID
            }));
          this.sicNames = legendsUsersData;
        },
        res => {
          this.$message.error(res.data.msg);
        }
      );
    },
    //查询条件重置
    btnRepeat() {
      this.selectData = {};
      this.getData();
    },
    //数据重置
    dataRepeat() {
      this.Data = {};
    }
  },
  mounted() {},
  components: {
    serviceItemsManageMain,
    staEndUse,
    dataTable
  },
  created() {
    this.getColumns();
    this.getData();
    this.getSic();
  }
};
</script>